Conversation
raejun92
approved these changes
Apr 2, 2026
Collaborator
raejun92
left a comment
There was a problem hiding this comment.
회고의 swap은 정말 생각도 못했네요! 고생하셨습니다
Collaborator
There was a problem hiding this comment.
저도 배열로 풀었는데ㅠ 투 포인터 방식을 익히면 좋을 것 같네요!
doitchuu
approved these changes
Apr 3, 2026
| } | ||
|
|
||
| return true; | ||
| }; |
Member
There was a problem hiding this comment.
오 left, right라는 변수명이 되게 직관적인 것 같아요.
투포인터를 활용해서도 많이 풀던데 이 방식대로 풀어도 좋을 것 같아요!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
이렇게 풀었어요
1. Palindrome Linked List
1) 복잡도 계산
시간 복잡도: O(n)
공간 복잡도: O(n)
2) 접근 아이디어
이 문제는 연결 리스트가 palindrome인지 판별하는 문제이다.
연결 리스트가 아직도 익숙하지 않기 때문에 그냥 값을 꺼내서 배열로 바꾸고 확인했다.
왼쪽 값과 오른쪽 값이 하나라도 다르면 바로 false를 반환하고, 끝까지 모두 같으면 true를 반환하도록 구현했다.
3) 회고
정석 풀이(?)는 리스트를 뒤집는 방식이라고 한다.
2. Move Zeroes
1) 복잡도 계산
시간 복잡도: O(n)
공간 복잡도: O(1)
2) 접근 아이디어
이 문제는 배열의 모든 0을 뒤로 보내면서, 0이 아닌 숫자들의 상대적인 순서는 유지해야 하는 문제이다. 0이 아닌 값들만 먼저 앞으로 모으고, 나머지 칸을 0으로 채우면 되겠다고 생각했다.
그래서 배열을 한 번 순회하면서 0이 아닌 값만 앞에서부터 차례대로 덮어썼다. 이때 idx를 두어 다음 non-zero 값을 넣을 위치를 관리했다. 순회가 끝난 뒤에는 idx 이후 남은 위치들을 전부 0으로 채우도록 구현했다. 이렇게 하면 0이 아닌 값들의 순서는 유지하면서, 0은 자연스럽게 뒤쪽으로 이동하게 된다.
3) 회고
이 문제는 swap으로 풀 수도 있을 것 같다.